package servlet;

import bean.Cinema;
import bean.VideoHall;
import dao.impl.CinemaDaoImpl;
import service.impl.VideoHallServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/get_cinemaId")
public class GetCinemaId extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String cinemaIdStr = request.getParameter("cinemaId");
        int cinema = Integer.parseInt(cinemaIdStr);
        CinemaDaoImpl cinemaDao = new CinemaDaoImpl();
         Cinema cinema1 = cinemaDao.getCinemaById(cinema);
         request.getSession().setAttribute("cinema",cinema1);
        VideoHallServiceImpl videoHallService = new VideoHallServiceImpl();
        List<VideoHall> videoHallList = videoHallService.getVideoHallByCinemaId(cinema);
        request.getSession().setAttribute("videoHallList",videoHallList);
    }
}
